package com.nbsaas.boot.nbtask.controller;

import jakarta.annotation.Resource;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.beans.factory.annotation.Lookup;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class WebController {


    @Resource
    private ObjectProvider<Test> prototypeBeanProvider;

    @Lookup
    public Test getPrototypeBean() {
        // 此处的返回值不会被调用，Spring会在运行时覆盖这个方法
        return null;
    }


    @RequestMapping(value = "/test")
    public String test() {
        Test test = prototypeBeanProvider.getObject();
        test.test();
        getPrototypeBean().test();
        return "Order submitted: ";
    }
}
